package com.binance.mbxgateway.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import com.binance.master.models.APIRequest;
import com.binance.master.models.APIResponse;
import com.binance.mbxgateway.api.ITradeRuleApi;
import com.binance.mbxgateway.vo.request.QueryAssetGasRequest;
import com.binance.mbxgateway.vo.request.QueryFeeRequest;
import com.binance.mbxgateway.vo.request.QueryUserProductFeeRequest;
import com.binance.mbxgateway.vo.request.RefreshTradingRuleRequest;
import com.binance.mbxgateway.web.service.ITradeRuleService;

@RestController
public class TradeRuleController implements ITradeRuleApi {

    @Autowired
    private ITradeRuleService tradeRuleService;

    @Override
    public APIResponse<Void> setAssetGas(@Validated @RequestBody APIRequest<QueryAssetGasRequest> request)
            throws Exception {
        this.tradeRuleService.setAssetGas(request.getBody());
        return APIResponse.getOKJsonResult();
    }

    @Override
    public APIResponse<Void> setUserProductFee(@Validated @RequestBody APIRequest<QueryUserProductFeeRequest> request)
            throws Exception {
        this.tradeRuleService.setUserProductFee(request.getBody());
        return APIResponse.getOKJsonResult();
    }

    @Override
    public APIResponse<Void> setFee(@Validated @RequestBody APIRequest<QueryFeeRequest> request) throws Exception {
        this.tradeRuleService.setFee(request.getBody());
        return APIResponse.getOKJsonResult();
    }

    @Override
    public APIResponse<Void> refreshTradingRule(@Validated @RequestBody APIRequest<RefreshTradingRuleRequest> request)
            throws Exception {
        this.tradeRuleService.refreshTradingRule(request.getBody());
        return APIResponse.getOKJsonResult();
    }

}
